setupfandomcom-20200216-history
GNU Emacs
has started]] Setting up GNU Emacs in Windows Installation 1. Go to http://ftp.gnu.org/pub/gnu/emacs/windows/ and download the latest zipped binary version of GNU Emacs (currently emacs-23.1-bin-i386.zip). 2. Extract the folder inside of the archive to a directory with a path name without spaces. 3. In the Emacs folder, the program that you want to run is bin\runemacs.exe. Create a shortcut to it on the desktop or in the start menu if you feel like it. 4. Also add the address of the bin folder to the system path, since some of the programs in the bin folder can be run as shell commands and other programs which work together with emacs may have to be able to call them. Setting up the variables The variables that stores the settings you wish to use are stored in the elisp source file called .emacs (located in your home directory). You can either change them manually directly in the source file or you can edit them through GNU Emacs by clicking (in the menu) Options->Customize Emacs->Top-level Customization Group. If you choose to change them manually you may have to restart Emacs after modyfying the file for the changes to take effect. Indentation When programming in C/C++ you may want to adjust the width that the indentation has. Or maybe you want to indent with tabs instead of spaces. The variables you want to change in that case are * c-basic-offset: The width of the indentation when writing C/C++ files (I have it set to 4) * indent-tabs-mode: Emacs can replace multiple spaces in the indentation with tabs (as many spaces as the tab width becomes one tab). For using this option, indent-tabs-mode should be set to t (for true), otherwise nil (for false). If you do use the option, c-basic-offset should preferably be set to something that is a multiple of the tab width. Be aware of that using tabs with a different tab width than the default (8 spaces) may result in unwanted behaviour (such as code being misaligned) when displaying the code in other programs, for example web browsers. * tab-width: the width of tab in number of spaces (the default that most programs use is 8). This can be changed by browsing for the appropriate options in Options->Customize Emacs->Top-level Customization Group, or by setting the variables in your .emacs file directly. Other options There are also some options you can change directly in the Options menu: You may want to activate Active Region Highlighting if you are not used to that the active region is not highlighted. If you are irritated by the blinking cursor there is an option for this too. If you want the scroll bar on the left side of the window you can change this by clicking Options->Show/Hide->Scroll-bar->On the Left. File type association In Windows Vista and later, it's not possible to associate file types with programs that are not located in certain standard program folders, such as the Program Files folder. To do a workaround on this problem, one can instead make a program that works as a middle hand, which with the file types are associated instead. The program, once started, opens Emacs, passing it the same arguments (except the first one which is the search path to the program) as it got itself. The program should be located in one of the standard program folders (for example Program Files), and to make it able to find Emacs, it is necessary that the address of the bin folder in the Emacs directory is added to the system path. Getting started with GNU Emacs Keyboard commands There are a number of Emacs commands that it is good to know about. There are a number of good pages on the web listing many useful Emacs commands, and here are some of them: * http://lpn.rnbhq.org/tools/xemacs/emacs_ref.html * http://www.cs.rutgers.edu/LCSR-Computing/some-docs/emacs-chart.html * http://www.cs.colostate.edu/helpdocs/emacs.html Otherwise, the most common of the commands are listed in the table bellow (here, C = Control, and M = Meta (alt or escape in windows)): Note that the keyboard commands differ notably from most other text editors; copy, paste and cut don't have the same commands, text can't be selected by holding down shift and moving the cursor and selected text isn't replaced if new text is entered or if text from the clip board is pasted. These are the differences that are the most notable, but one will get used to them after a while. Minibuffer commands There are also a number of useful minibuffer commands, which you enter in the minibuffer by first pressing M-x. Minibuffer commands are used in more special occasions, hence the longer names. A list of commands that can be entered can also be shown by pressing tab when entering a command in the minibuffer. Undoing From gnu.org: "Emacs' undo facility works slightly differently from that of other editors. In most editors, if you undo some changes, then make some new changes, the states formerly accessible with "redo" can no longer be recovered! So when using "undo" and "redo" extensively, one has to be very careful to avoid accidentally clobbering the redo list. Emacs uses a different undo model which does not have this deficiency. After any consecutive sequence of undos, Emacs makes all your previous actions undoable, including the undos. (This will happen whenever a sequence of undos is broken by any other command.) If this sounds complicated, just remember that "undo" is always capable of getting you back to any previous state your buffer was in (unless Emacs has run out of memory to store the undo history). The principle here is that Emacs makes it very difficult to accidentally lose your work." Compiling When compiling a project from Emacs, the best thing is to learn how to use a makefile, and write one. When compiling, enter a buffer that contains a file which is in the same directory as the makefile (maybe the makefile it self’s buffer), and type M-x compile. A standard shell line will now be displayed in the minibuffer ("make -k"), which can be modified, and when return is pressed the content of the minibuffer is run as a shell command. To use make, MSYS must be installed and set up properly, otherwise MinGW contains a program called mingw32-make.exe which works as make.exe. On the other hand, MSYS contains many programs which are common Linux shell commands, so it is good to have MSYS installed too. Then make.exe will call the compiler in question, for which you need to have MinGW installed and set up properly. You will need to have both MinGW's and MSYS' bin folders added to your system path. External links EmacsWiki, a whole wiki about Emacs